<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

    <title>发表评论</title>

    <link href="__PUBLIC__/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css">

    <link href="__PUBLIC__/css/personal.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/css/appstyle.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="__PUBLIC__/AmazeUI-2.4.2/assets/css/uploadView.css">
    <script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.2.min.js"></script>
</head>

<body>

<div class="center">
    <div class="col-main">
        <div class="main-wrap">

            <div class="user-comment">
                <!--标题 -->
                <div class="am-cf am-padding">
                    <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">发表评论</strong> /
                        <small>Make&nbsp;Comments</small>
                    </div>
                </div>
                <hr/>

                <div class="comment-main">
                    <input type="hidden" id="order_id" value="{$order.order_id}">
                    <input type="hidden" id="goods_count" value="{$order.goods_count}">
                    <volist name="order.goodsList" id="goods">
                        <input type="hidden" class="order-goods-id" value="{$goods.goods_id}">
                        <input type="hidden" class="order-rec-id" value="{$goods.rec_id}">
                        <div class="comment-list">
                            <div class="item-pic">
                                <a href="#" class="J_MakePoint">
                                    <img src="{$goods.image_url}" class="itempic">
                                </a>
                            </div>

                            <div class="item-title">

                                <div class="item-name">
                                    <a href="#">
                                        <p class="item-basic-info">{$goods.goods_name}</p>
                                    </a>
                                </div>
                                <div class="item-info">
                                    <div class="info-little">
                                        <!--<span>颜色：洛阳牡丹</span>-->
                                        <!--<span>包装：裸装</span>-->
                                        <span>{$goods.spec_key_name}</span>
                                    </div>
                                    <div class="item-price">
                                        价格：<strong>{$goods.goods_price}元</strong>
                                    </div>
                                </div>
                            </div>
                            <div class="clear"></div>
                            <div class="item-comment">
                                <textarea placeholder="请写下对宝贝的感受吧，对他人帮助很大哦！" class="comment-content" name="contents[]"></textarea>
                            </div>
                            <div class="am-form-group" style="margin-top: 5px">
                                <div class="control-group js_uploadBox">
                                    <div class="am-u-sm-3 " id="divi" onclick="deleteInput('i')">
                                        <div class="btn-upload">
                                            <a href="javascript:void(0);"><i class="am-icon-picture-o am-icon-md" style="color:rgba(0,0,0,0.4)"></i><span class="js_uploadText" style="font-size:24px"></span></a>
                                            <input id="js_upFile" class="js_upFile" data-order_goods_id="{$goods.rec_id}" type="file" name="cover[]">
                                        </div>
                                        <div class="js_showBox"></div>
                                    </div>
                                </div>
                            </div>
                            <div class="item-opinion">
                                <li><i class="op1 comment-item" data-value="1"></i>好评</li>
                                <li><i class="op2 comment-item" data-value="2"></i>中评</li>
                                <li><i class="op3 comment-item" data-value="3"></i>差评</li>
                            </div>
                        </div>
                    </volist>

                    <div class="info-btn">
                        <div class="am-btn am-btn-danger" onclick="addComment()">发表评论</div>
                    </div>
                    <script type="text/javascript">
                        $(document).ready(function () {
                            $(".comment-list .item-opinion li").click(function () {
                                $(this).prevAll().children('i').removeClass("active");
                                $(this).nextAll().children('i').removeClass("active");
                                $(this).children('i').addClass("active");

                            });
                        })
                    </script>


                </div>

            </div>

        </div>
        <!--底部-->

    </div>


</div>

</body>

</html>
<script type="text/javascript" src="__PUBLIC__/basic/js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/AmazeUI-2.4.2/assets/js/amazeui.js"></script>
<script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>
<script src="__PUBLIC__/AmazeUI-2.4.2/assets/js/jquery.uploadView.js"></script>
<script src="__PUBLIC__/AmazeUI-2.4.2/assets/js/jquery.uploadView.add.js"></script>
<script>
    function modalInfo(info,success){
            layer.msg(info);
//            if(success) {
//                layer.msg(info, {icon: 1});
//            }else{
//                layer.msg(info, {icon: 2});
//            }

    }
    function addComment() {
        var order_id = $('#order_id').val();
        var goods_count = $('#goods_count').val();
        var id;
        var imageArrays = new Map();
        $('.js_upFile').each(function(index,item) {
            var currentId = $(this).data('order_goods_id');
            console.info(currentId);
            if (typeof(currentId) != "undefined") {
                id = currentId;
            }
            imageArrays.set('order_goods_id',id);
            imageArrays.set('imageUrl',$(this));
        });
        console.info(imageArrays);
        return;
        console.info(goods_count);
        var evaluates = new Array();
        var contents = new Array();
        var ids = new Array();
        var rec_ids = new Array();
        $('.comment-list .item-comment .comment-content').each(function (index,item) {
            console.info(this);
            contents[index] = $(this).val();
        });
        console.info(contents);
        $('.comment-list .item-opinion .comment-item.active').each(function (index,item) {
             evaluates[index] = $(this).data('value');
        });
        $('.order-goods-id').each(function (index,item) {
            ids[index] = $(this).val();
        });
        $('.order-rec-id').each(function (index,item) {
            rec_ids[index] = $(this).val();
        });
        if(evaluates.length != goods_count){
            modalInfo('请选择评价类型！',false);
            return;
        }
        if(contents.length != goods_count){
            modalInfo('请填写完整评论内容！',false);
            return;
        }
        $.ajax({
            url:"__APP__/Home/Order/addComment",
            type:"post",
            data:{
                order_id:order_id,
                evaluates:evaluates,
                contents:contents,
                goods_ids:ids,
                rec_ids:rec_ids
            },
            success: function(data){
                modalInfo(data.message,data.success);
                layer.msg(data.message,function(){
                    window.location.href = '__APP__/Home/Order/index?type=0';
                });
            },
            error:function (data) {
                modalInfo('服务器繁忙！',false);
            }
        });
    }
</script>